package com.taotao.job.core.executor;

import com.alibaba.fastjson.JSON;
import lombok.Getter;

/**
 * execute方法运行结果
 *
 * @author fanbeibei
 * @version 1.0
 * @date 2021/2/4 14:19
 */
@Getter
public class ExecuteReturn {
    public static final String RESULT_SUCCESS = "success";
    public static final String RESULT_FAIL = "fail";

    private String result;

    private String msg;


    private ExecuteReturn(String result, String msg) {
        this.result = result;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    /**
     * 运行成功的返回
     *
     * @param msg
     * @return
     */
    public static ExecuteReturn successExecuteReturn(String msg) {
        return new ExecuteReturn(RESULT_SUCCESS, msg);
    }

    public static ExecuteReturn successExecuteReturn() {
        return new ExecuteReturn(RESULT_SUCCESS, null);
    }


    /**
     * 运行失败的返回
     *
     * @param msg
     * @param
     * @return
     */
    public static ExecuteReturn failExecuteReturn(String msg) {
        return new ExecuteReturn(RESULT_FAIL, msg);
    }

}
